package com.towker.web.tags;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class CommonFunction {
	/**
	 * 获取订单状态说明
	 * @param status
	 * @return
	 */
	public static String getOrderStatusText(Integer status) {
		if(status == 0) {
			return "订购单未递交到下一级";
		}else if(status == 1) {
			return "已经递交到订单报价";
		} else if(status == 2) {
			return "已经递交到订单确认";
		} else if(status == 3) {
			return "已经递交到订单审核";
		} else if(status == 4) {
			return "已经审核并已经转到送货单复制";
		} else if(status == 5) {
			return "已经复制到送货单中";
		}else if(status == 6) {
			return "用户取消";
		}else if(status == 7) {
			return "审核不通过";
		}  else {
			return "";
		}
	}
	/**
	 * 获取送货单状态说明
	 * @param status
	 * @return
	 */
	public static String getDeliveryStatusText(Integer status) {
		if(status == 0) {
			return "未递交到仓库送货";
		}else if(status == 1) {
			return "已经递交到仓库送货";
		} else {
			return "";
		}
	}
	/**
	 * 获取代销单状态说明
	 * @param status
	 * @return
	 */
	public static String getConsignmentStatusText(Integer status) {
		if(status == 1) {
			return "已经审核";
		}else if(status == 2) {
			return "已经记账";
		} else if (status == 3) {
			return "已经审核并记账";
		} else {
			return "";
		}
	}
	public static String getInvoiceAttachmentStatusText(Integer status) {
		if(status == 1) {
			return "已经打印正式发票";
		}else if(status == 2) {
			return "已经记账";
		} else if (status == 3) {
			return "已经打印正式发票并记账";
		} else {
			return "";
		}
	}
	public static String getInvoiceTypeText(Integer type) {
		if(type == 1) {
			return "普通发票";
		}else if(type == 2) {
			return "增值税发票";
		} else {
			return "";
		}
	}
	public static String getUserStatusText(Integer userStatus) {
		if(userStatus == 1) {
			return "申请中";
		}else if(userStatus == 2) {
			return "拒绝";
		} else  if(userStatus == 3) {
			return "正式用户";
		}else{
			return "";
		}
	}
	
	public static String getProAppTypeText(Integer status) {
		//1、销售  2、库存  3、固定  4、临时
		if(status == 1) {
			return "销售";
		}else if(status == 2) {
			return "库存";
		} else  if(status == 3) {
			return "固定";
		}else  if(status == 4) {
			return "临时";
		}else{
			return "";
		}
	}
	
	public static String getProAppStatusText(Integer status) {
		//0、申请单未递交到生产部  1、已经递交到生产部  2、已经安排生产  3、已经生产完成
		if (status == 0) {
			return "申请单未递交到生产部";
		} else if(status == 1) {
			return "未审核";
		}else if(status == 2) {
			return "通过审核安排生产";
		} else  if(status == 3) {
			return "已经生产完成";
		}else{
			return "";
		}
	}
	
	public static String formatDate(Object value, String pattern) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat sdfFormat = new SimpleDateFormat(pattern);
		if (value == null) {
			return "";
		} else if (value instanceof Date) {
			return sdfFormat.format(value);
		} else {
			String s = value.toString();
			try {
				Date d = sdf.parse(s);
				return sdfFormat.format(d);
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}		
		return "";
	}
}
